﻿/// <reference path="references.scss" />


/* PARENT CANVAS
--------------------------------------------*/

.canvas-slidable {
    z-index: 0;
    transition: opacity $offcanvas-duration $offcanvas-easing,
                transform $offcanvas-duration $offcanvas-easing;

    .canvas-sliding-start &                         { transform: translate3d(15%, 0, 0); }
    .canvas-sliding-end &                           { transform: translate3d(-15%, 0, 0); }
    .canvas-sliding-bottom &                        { transform: translate3d(0, -15vh, 0); }
    .canvas-sliding-top &                           { transform: translate3d(0, 15vh, 0); }

    .canvas-fullscreen &                            { box-shadow: none !important; }
}

body.canvas-noscroll {
    overflow: hidden;
    width: 100%;
    height: 100%;
}


/* TOGGLER
--------------------------------------------*/

.navbar-toggler { 
    position: relative;
    background-color: transparent;
    outline: none;
    &:focus { outline: none }
}


/* PARENT CANVAS BLOCKER
--------------------------------------------*/

.canvas-blocker {
    position: fixed;
    z-index: 0 !important;
    width: 100%;
    top: 0;
    bottom: 0;
    background-color: #000;
    opacity: 0;
    transition: opacity $offcanvas-duration $offcanvas-easing,
                transform $offcanvas-duration $offcanvas-easing,
                z-index 0s linear $offcanvas-duration;

    overflow: hidden;
}

body.canvas-blocking .canvas-blocker {
    z-index: $zindex-fixed+1 !important;
    opacity: 0.3;
    transition: opacity $offcanvas-duration $offcanvas-easing,
                transform $offcanvas-duration $offcanvas-easing,
                z-index 0s 0s !important;

}


/* OFFCANVAS ELEMENT
--------------------------------------------*/

.offcanvas {
    --offcanvas-width: #{$offcanvas-width};
    --offcanvas-height: 100vh;
    --offcanvas-border-radius: 0;
    --offcanvas-top: 0;
    --offcanvas-x-offset: -100%;
    --offcanvas-y-offset: 0;
    --offcanvas-padding-x: 1.5rem;
    --offcanvas-padding-y: 1.5rem;
    --offcanvas-header-border-color: var(--border-color);
    --offcanvas-header-border-width: 1px;

    position: fixed;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    visibility: hidden;
    outline: 0;
    margin: 0; 
    background-color: #fff;
    overflow-x: auto;
    z-index: $offcanvas-z-index;
    transition: transform $offcanvas-duration $offcanvas-easing,
                opacity $offcanvas-duration $offcanvas-easing, 
                visibility 0s ease $offcanvas-duration;

    width: var(--offcanvas-width);
    height: var(--offcanvas-height);
    top: var(--offcanvas-top);
    inset-inline-start: 0;
    transform: translate3d(var(--offcanvas-x-offset), var(--offcanvas-y-offset), 0);
    @include border-right-radius(var(--offcanvas-border-radius));

    &.offcanvas-rounded {
        --offcanvas-border-radius: var(--border-radius-xl);
    }

    &.offcanvas-lg {
        --offcanvas-width: #{$offcanvas-width-lg};
    }

    &.offcanvas-end {
        --offcanvas-x-offset: 100%;
        inset-inline-start: auto !important;
        inset-inline-end: 0;
        @include border-right-radius(0);
        @include border-left-radius(var(--offcanvas-border-radius));
    }

    &:is(offcanvas-top, .offcanvas-bottom) {
        --offcanvas-x-offset: 0;
        --offcanvas-width: 100%;
        --offcanvas-height: 80vh;
    }

    &.offcanvas-top {
        --offcanvas-y-offset: -100%;
        top: 0;
        @include border-top-radius(0);
        @include border-bottom-radius(var(--offcanvas-border-radius));
    }

    &.offcanvas-bottom {
        --offcanvas-y-offset: 100%;
        bottom: 0;
        top: auto;
        @include border-bottom-radius(0);
        @include border-top-radius(var(--offcanvas-border-radius));
    }

    &.offcanvas-fullscreen {
        --offcanvas-width: 100%;
        --offcanvas-border-radius: 0;
    }

    &.offcanvas-shadow {
        box-shadow: $offcanvas-shadow;
    }

    @media (max-width: $offcanvas-width) {
        &.offcanvas:not(.offcanvas-top, .offcanvas-bottom) {
            --offcanvas-width: 100% !important;
            --offcanvas-border-radius: 0;
        }
    }

    @media (max-width: $offcanvas-width-lg) {
        &.offcanvas-lg:not(.offcanvas-top, .offcanvas-bottom) {
            --offcanvas-width: 100% !important;
            --offcanvas-border-radius: 0;
        }
    }

    &.show {
        --offcanvas-x-offset: 0 !important;
        --offcanvas-y-offset: 0 !important;
        opacity: 1;
        visibility: visible;
        transition: transform $offcanvas-duration $offcanvas-easing,
                    opacity $offcanvas-duration $offcanvas-easing;
    }
}

.offcanvas-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    align-self: stretch;
    justify-content: space-between;
    padding: var(--offcanvas-padding-y) var(--offcanvas-padding-x);
    border-bottom: var(--offcanvas-header-border-width) solid var(--offcanvas-header-border-color);
}

.offcanvas-title {
    margin-bottom: 0;
}

.offcanvas-body {
    padding: var(--offcanvas-padding-y) var(--offcanvas-padding-x);
}

.offcanvas-content {
    position: absolute;
    width: 100%;
    // We place two height values here to support all browsers. Some browsers don't support 100dvh yet.
    height: 100vh;
    height: 100dvh;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.offcanvas-header + .offcanvas-content {
    position: relative;
    height: auto;
    flex-grow: 1;
    overflow-y: auto;
}

.offcanvas-scrollable {
    touch-action: pan-y;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}


/* OFFCANVAS TABS
--------------------------------------------*/

.offcanvas-tabs {
    position: relative;
    flex-grow: 0;
    padding: 0;

    .offcanvas-closer {
        border-radius: 0;
    }

    .nav-tabs {
        display: flex;
        flex-direction: row;
        overflow-x: hidden;
        overflow-y: hidden;
        flex-wrap: nowrap;

        .touchevents & { overflow-x: auto; }
    }

    .nav-item {
        display: block;
        flex-wrap: nowrap;
        white-space: nowrap;
    }

    .nav-link {
		border-radius: 0;
        max-width: 100%;
        padding-top: 1rem;
        padding-bottom: 1rem;
		color: $gray-600;

        &.active {
			font-weight: $font-weight-medium;
        }

        .badge {
            position: relative;
            inset-inline-end: 0;
            top: 0;
        }
    }

    @media (max-width: 480px) {
        .nav-link {
            padding-inline: 0.5rem;
        }
    }
}


/* LAYOUT OVERRIDES
--------------------------------------------*/

.canvas-overlay {
    .page-main      { box-shadow: none; }
    .canvas-blocker { width: 200%; left: -50% }
}


/* RTL support
--------------------------------------------*/

[dir=rtl] {
    .canvas-sliding-start .canvas-slidable {
        transform: translate3d(-15%, 0, 0);
    }

    .canvas-sliding-end .canvas-slidable {
        transform: translate3d(15%, 0, 0);
    }

    .offcanvas {
        --offcanvas-x-offset: 100%;

        &.offcanvas-end {
            --offcanvas-x-offset: -100%;
        }
    }
}